import { defHttp } from '/@/utils/http/axios';
import {
  IAddDocLabel,
  IDeleteDocLabel,
  IUpdateDocLabel,
  IQueryDocLabel,
  IDeleteFlowTemplate,
  IGetAllFlowTemplate,
  IGetFlowTemplate,
  IAddFlowTemplate,
  IUpdateFlowTemplate,
  IGetAllToDoList,
  IGetAllSignature,
  IGetAllContinueSignature,
  IGetAllBackSignature,
  IGetAllSelectBackSignature,
  IGetAllBackStep,
  IDeleteToDoList,
  IGetAllProcessDetails,
  IGetAllCreateProcess,
} from './model/flowModel';

enum Api {
  Flow_Add = '/services/app/DocLabel/AddDocLabel',
  Flow_Update = '/services/app/DocLabel/UpdateDocLabel',
  Flow_Get = '/services/app/DocLabel/GetDocLabelInfo',
  FlowTemplate_Add = '/services/app/Workflows/AddAllWorkflowData',
  FlowTemplate_Update = '/services/app/Workflows/UpdateWorkflowWebData',
  FlowSignature = '/services/app/WorkflowInstances/WorkflowstepsiJudge',
  FlowContinueSignature = '/services/app/WorkflowInstances/WorkflowstepContinue',
  FlowBackSignature = '/services/app/WorkflowInstances/SelectRebackstep',
  FlowSelectBackSignature = '/services/app/WorkflowInstances/RebackSelectstep',
  FlowBackStep = '/services/app/WorkflowInstances/Rebackstep',
  Flow_Delete = '/services/app/Task/Deleteworkflows',
  Flow_AllProcessDetails = '/services/app/Task/GetWorkflowinsDetails',
  GetParticipant = '/services/app/Persons/Getallpersondto',
  GetAllCreateProcess = '/services/app/WorkflowInstances/AddAllWorkflow',
}
/**
 * 模块名:删除流程模板数据
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/16 14:26:03
 */
export const deleteFlowTemplate = (params: IDeleteFlowTemplate) =>
  defHttp.delete({ url: `/services/app/Workflows/DeleteWorkflowWebData?Workflowid=${params}` });

/**
 * 模块名:获取所有流程模板数据
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2023/12/19 10:19:07
 */
export const flowListApi = (params: IGetAllFlowTemplate) =>
  defHttp.get({
    url: `/services/app/Workflows/GetallWorkflows?WorkflowsName=${params}`,
  });
export const newFlowListApi = (WorkflowsId: string) =>
  defHttp.get({
    url: `/services/app/Workflows/GetAllWorkflowsLikeId?WorkflowsId=${WorkflowsId}`,
  });

/**
 * 模块名:查看流程模板数据
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/16 15:10:06
 */
export const getFlowTemplateApi = (params: IGetFlowTemplate) =>
  defHttp.get({
    url: `/services/app/Workflows/GetWorkflowWebData?Workflowid=${params}`,
  });

/**
 * 模块名:新增流程模板
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/17 13:21:38
 */
export const addFlowTemplateApi = (params: IAddFlowTemplate) =>
  defHttp.post({ url: Api.FlowTemplate_Add, params });

/**
 * 模块名:修改流程模板
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/17 13:24:58
 */
export const updateFlowTemplateApi = (params: IUpdateFlowTemplate) =>
  defHttp.put({ url: Api.FlowTemplate_Update, params });

/**
 * 模块名:标签添加
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/11 15:12:37
 */
export const addDocLabelApi = (params: IAddDocLabel) =>
  defHttp.post({
    url: Api.Flow_Add,
    params,
  });

/**
 * 模块名:标签删除
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/15 11:44:26
 */
export const deleteDocLabelApi = (params: IDeleteDocLabel) =>
  defHttp.delete({ url: `/services/app/DocLabel/DeleteDocLabelInfo?LabelID=${params}` });

/**
 * 模块名:标签修改
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/15 11:03:10
 */
export const updateDocLabelApi = (params: IUpdateDocLabel) =>
  defHttp.put({
    url: Api.Flow_Update,
    params,
  });

/**
 * 模块名:标签查看
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/15 11:45:49
 */
export const getDocLabelApi = (params: IQueryDocLabel) =>
  defHttp.get({
    url: Api.Flow_Get,
    params,
  });

/**
 * 模块名:待办流程
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/22 10:06:32
 */
export const getFlowToDoListApi = (params: IGetAllToDoList) =>
  defHttp.post({
    url: `/services/app/Task/SelectNowPersonWorkflow`,
    params,
  });

/**
 * 模块名:签字
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/22 13:21:45
 */
export const signFlowApi = (params: IGetAllSignature) =>
  defHttp.post({
    url: Api.FlowSignature,
    params,
  });

/**
 * 模块名:继续签字
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/22 14:01:35
 */
export const continueSignFlowApi = (params: IGetAllContinueSignature) =>
  defHttp.post({
    url: Api.FlowContinueSignature,
    params,
  });

/**
 * 模块名:退回
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/22 14:58:06
 */
export const backFlowApi = (params: IGetAllBackSignature) =>
  defHttp.post({
    url: Api.FlowBackSignature,
    params,
  });

/**
 * 模块名:选择回退
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/22 15:50:37
 */
export const selectBackFlowApi = (params: IGetAllSelectBackSignature) =>
  defHttp.post({ url: Api.FlowSelectBackSignature, params });

/**
 * 模块名:退回步骤
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/22 15:57:56
 */
export const backStepFlowApi = (params: IGetAllBackStep) =>
  defHttp.post({ url: Api.FlowBackStep, params });

/**
 * 模块名:删除待办流程
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/23 14:27:46
 */
export const deleteFlowApi = (params: IDeleteToDoList) =>
  defHttp.post({ url: Api.Flow_Delete, params });

/**
 * 模块名:流程详情
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/23 14:45:17
 */
export const flowDetailApi = (params: IGetAllProcessDetails) =>
  defHttp.get({ url: Api.Flow_AllProcessDetails, params });

/**
 * 模块名:下载文件
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/24 09:14:28
 */
export const downloadFileApi = (oid: string) =>
  defHttp.get({ url: `/services/app/BinaryFiles/DownLoadFile?oid=${oid}` });

/**
 * 模块名:检入流程
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/24 14:34:52
 */
export const checkInFlowApi = (userid: string | number, oid: string) =>
  defHttp.get({ url: `/services/app/WorkflowInstances/GetListWorkf?userid=${userid}&oid=${oid}` });

/**
 * 模块名:获取代号，名称
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/24 15:28:43
 */
export const getCodeNameApi = (WorkflowType: string, filename: string, fileVersion: string) =>
  defHttp.get({
    url: `/services/app/WorkflowInstances/GetWfs?WorkflowType=${WorkflowType}&filename=${filename}&fileVersion=${fileVersion}`,
  });

/**
 * 模块名:获取信息提示
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/24 15:47:25
 */
export const getInfoTipsApi = (msgId: string) =>
  defHttp.get({ url: `/services/app/TiPDMMsgCustom/GetMsgCustom?msgId=${msgId}` });

/**
 * 模块名:获取步骤
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/24 15:52:23
 */
export const getStepApi = (id: string) =>
  defHttp.get({ url: `/services/app/Steps/GetStepsnoEntry?id=${id}` });

/**
 * 模块名:通用流程
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/24 16:23:23
 */
export const getCommonFlowApi = (id: string, name: string) =>
  defHttp.get({ url: `/services/app/Workflows/GetList?id=${id}&name=${name}` });

/**
 * 模块名:获取参与者，负责人
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/24 16:33:17
 */
export const getParticipantApi = () => defHttp.get({ url: Api.GetParticipant });

/**
 * 模块名:多对象检入
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/24 16:48:08
 */
export const getCheckInApi = (userid: string | number, oids: string) =>
  defHttp.get({
    url: `/services/app/WorkflowInstances/GetListWorkfByBatch?userid=${userid}&oids=${oids}`,
  });

/**
 * 模块名:新建流程
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/24 17:32:51
 */
export const getNewFlowApi = (params: IGetAllCreateProcess) =>
  defHttp.post({ url: Api.GetAllCreateProcess, params });

/**
 * 模块名:发起流程
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/25 11:50:14
 */
export const getStartFlowApi = (id: string) =>
  defHttp.get({ url: `/services/app/PdmDocmaster/GetDocMasterInfo?id=${id}` });

/**
 * 模块名:数据目录
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/01/25 09:57:29
 */
export const getDataDirectoryApi = (superid: number) =>
  defHttp.get({ url: `/services/app/Prdfolder/GetTest?superid=${superid}` });

/**
 * 模块名:查询所有图档类型数据
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/02/04 15:12:15
 */
export const getAllDocTypeApi = () =>
  defHttp.get({ url: `/services/app/Pdmdoctype/GetALLFilePdmDocType` });

/**
 * 模块名:获取对应文件类型和流程类型模板列表
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/02/20 09:32:26
 */
export const getTemplateList = (FileType: string, WorkflowType: string) =>
  defHttp.get({
    url: `/services/app/Workflows/GetWorkflowsListUseType?FileType=${FileType}&WorkflowType=${WorkflowType}`,
  });

/**
 * 模块名:获取对应文件/零件类型废止流程模板列表
 * 代码描述:
 * 作者:张泽源
 * 创建时间:2024/04/11 14:05:22
 */
export const getTemplateListByType = (FileType: string) =>
  defHttp.get({
    url: `/services/app/Workflows/GetEndWorkflowUseType?FileType=${FileType}`,
  });
